<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>混合 (mixins) </title>
  <script src="vue.js"></script>
</head>
<body>
<script>
  // 定义一个混合对象
  var myMixin = {
    created () {
      this.main()
    },
    methods: {
      main () {
        console.log('main from mixin!')
      }
    }
  }
  // 定义一个使用混合对象的组件
  var Component = Vue.extend({
    mixins: [myMixin]
  })
  var component = new Component()  // -> "main from mixin!"
</script>
</body>
</html>